cmake build system: visiblity support for clang
[supercollider.git] / Help / UGens / Playback and Recording / RecordBuf.html
blobb4bff9e37fad10c1f703bb2343c04d74bbacea5c
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.43">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 56.0px; text-indent: -56.0px; font: 12.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #2c7014}
18 span.s1 {color: #001bb9}
19 span.s2 {color: #000000}
20 span.s3 {color: #2c7014}
21 span.s4 {color: #606060}
22 span.s5 {color: #ad140d}
23 span.Apple-tab-span {white-space:pre}
24 </style>
25 </head>
26 <body>
27 <p class="p1"><b>RecordBuf<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>record or overdub into a Buffer</b></p>
28 <p class="p2"><br></p>
29 <p class="p3">Records input into a <a href="../../ServerArchitecture/Buffer.html"><span class="s1">Buffer</span></a>.</p>
30 <p class="p4"><br></p>
31 <p class="p3"><b>RecordBuf.ar(inputArray, bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction)</b></p>
32 <p class="p3"><b>RecordBuf.kr(inputArray, bufnum, offset, recLevel, preLevel, run, loop, trigger, doneAction)</b></p>
33 <p class="p4"><br></p>
34 <p class="p3">If recLevel is 1.0 and preLevel is 0.0 then the new input overwrites the old data.</p>
35 <p class="p3">If they are both 1.0 then the new data is added to the existing data. (Any other settings</p>
36 <p class="p3">are also valid.)</p>
37 <p class="p4"><br></p>
38 <p class="p3"><span class="Apple-tab-span"> </span><b>inputArray</b> - an Array of input channels</p>
39 <p class="p3"><span class="Apple-tab-span"> </span><b>bufnum</b> - the index of the buffer to use</p>
40 <p class="p3"><span class="Apple-tab-span"> </span><b>offset</b> <span class="Apple-converted-space">  </span>- an offset into the buffer in frames, the default is 0.0.</p>
41 <p class="p3"><span class="Apple-tab-span"> </span><b>recLevel</b> - value to multiply by input before mixing with existing data. Default is 1.0.</p>
42 <p class="p3"><b><span class="Apple-tab-span"> </span>preLevel</b> - value to multiply to existing data in buffer before mixing with input. Default is 0.0.</p>
43 <p class="p3"><span class="Apple-tab-span"> </span><b>run</b> - If zero, then recording stops, otherwise recording proceeds. Default is 1.</p>
44 <p class="p3"><span class="Apple-tab-span"> </span><b>loop</b><span class="Apple-converted-space">  </span>- If zero then don't loop, otherwise do.<span class="Apple-converted-space">  </span>This is modulate-able. Default is 1.</p>
45 <p class="p3"><span class="Apple-tab-span"> </span><b>trigger</b> - a trigger causes a jump to the <b>offset</b> position in the Buffer.<span class="Apple-converted-space"> </span></p>
46 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>A trigger occurs when a signal changes from &lt;= 0 to &gt; 0.</p>
47 <p class="p5"><span class="Apple-tab-span"> </span><b>doneAction</b> - an integer representing an action to be executed when the buffer is finished playing. This can be used to free the enclosing synth, etc. See <a href="../Synth control/Envelopes/UGen-doneActions.html"><span class="s1">UGen-doneActions</span></a> for more detail.</p>
48 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>doneAction is only evaluated if <b>loop</b> is 0.</p>
49 <p class="p2"><br></p>
50 <p class="p2"><br></p>
51 <p class="p3">Note that the<b> number of channels</b> must be fixed for the SynthDef, it cannot vary depending on which buffer you use.</p>
52 <p class="p2"><br></p>
53 <p class="p6">// Execute the following in order</p>
54 <p class="p7">(</p>
55 <p class="p6">// allocate a Buffer</p>
56 <p class="p7">s = <span class="s1">Server</span>.local;</p>
57 <p class="p6"><span class="s2">b = </span><span class="s1">Buffer</span><span class="s2">.alloc(s, 44100 * 4.0, 1); </span>// a four second 1 channel Buffer</p>
58 <p class="p7">)</p>
59 <p class="p2"><br></p>
60 <p class="p6">// record for four seconds</p>
61 <p class="p7">(</p>
62 <p class="p7"><span class="s1">SynthDef</span>(<span class="s3">\help_RecordBuf</span>, { <span class="s1">arg</span> out = 0, bufnum = 0;</p>
63 <p class="p7"><span class="Apple-tab-span"> </span><span class="s1">var</span> formant;</p>
64 <p class="p7"><span class="Apple-tab-span"> </span>formant = <span class="s1">Formant</span>.ar(<span class="s1">XLine</span>.kr(400,1000, 4), 2000, 800, 0.125);</p>
65 <p class="p7"><span class="Apple-tab-span"> </span><span class="s1">RecordBuf</span>.ar(formant, bufnum, doneAction: 2, loop: 0);</p>
66 <p class="p7">}).play(s,[<span class="s3">\out</span>, 0, <span class="s3">\bufnum</span>, b]);</p>
67 <p class="p7">)</p>
68 <p class="p2"><br></p>
69 <p class="p6">// play it back</p>
70 <p class="p7">(</p>
71 <p class="p7"><span class="s1">SynthDef</span>(<span class="s3">\help_RecordBuf_overdub</span>, { <span class="s1">arg</span> out = 0, bufnum = 0;</p>
72 <p class="p7"><span class="Apple-tab-span"> </span><span class="s1">var</span> playbuf;</p>
73 <p class="p7"><span class="Apple-tab-span"> </span>playbuf = <span class="s1">PlayBuf</span>.ar(1,bufnum);</p>
74 <p class="p6"><span class="s2"><span class="Apple-tab-span"> </span></span><span class="s1">FreeSelfWhenDone</span><span class="s2">.kr(playbuf); </span>// frees the synth when the PlayBuf is finished</p>
75 <p class="p7"><span class="Apple-tab-span"> </span><span class="s1">Out</span>.ar(out, playbuf);</p>
76 <p class="p7">}).play(s, [<span class="s3">\out</span>, 0, <span class="s3">\bufnum</span>, b]);</p>
77 <p class="p7">)</p>
78 <p class="p2"><br></p>
79 <p class="p6">// overdub</p>
80 <p class="p7">(</p>
81 <p class="p8"><span class="s1">SynthDef</span><span class="s2">(</span>\help_RecordBuf_overdub<span class="s2">, { </span><span class="s1">arg</span><span class="s2"> out=0, bufnum=0;</span></p>
82 <p class="p7"><span class="Apple-tab-span"> </span><span class="s1">var</span> formant;</p>
83 <p class="p7"><span class="Apple-tab-span"> </span>formant = <span class="s1">Formant</span>.ar(<span class="s1">XLine</span>.kr(200, 1000, 4), 2000, 800, 0.125);</p>
84 <p class="p6"><span class="s2"><span class="Apple-tab-span"> </span></span>// mixes equally with existing data</p>
85 <p class="p7"><span class="Apple-tab-span"> </span><span class="s1">RecordBuf</span>.ar(formant, bufnum, 0, 0.5, 0.5, doneAction: 2, loop: 0);<span class="Apple-converted-space"> </span></p>
86 <p class="p7">}).play(s, [<span class="s3">\out</span>, 0, <span class="s3">\bufnum</span>, b]);</p>
87 <p class="p7">)</p>
88 <p class="p2"><br></p>
89 <p class="p6">// play back the overdubbed version</p>
90 <p class="p8"><span class="s1">Synth</span><span class="s2">.new(</span>\help_RecordBuf_overdub<span class="s2">, [</span>\out<span class="s2">, 0, </span>\bufnum<span class="s2">, b], s);</span></p>
91 <p class="p2"><br></p>
92 <p class="p6">// write the contents of the buffer to a file (see <a href="../../ServerArchitecture/Buffer.html"><span class="s1">Buffer</span></a> for more options)</p>
93 <p class="p6">(</p>
94 <p class="p7">b.write(sampleFormat: <span class="s3">'int16'</span>);</p>
95 <p class="p7"><span class="s1">thisProcess</span>.platform.recordingsDir +/+ <span class="s4">"SC_"</span> ++ <span class="s1">Date</span>.localtime.stamp ++ <span class="s4">".aiff"</span>; <span class="s5">// generated path</span></p>
96 <p class="p7">)</p>
97 <p class="p2"><br></p>
98 <p class="p2"><br></p>
99 <p class="p7">b.close; b.free; <span class="s5">// cleanup</span></p>
100 <p class="p4"><br></p>
101 <p class="p2"><br></p>
102 </body>
103 </html>